package com.zxtech.zzm.zxmonitorsu

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.widget.TextView
import com.zxtech.zzm.core.util.DeviceUtil
import com.zxtech.zzm.core.util.DeviceUtil.Companion
import com.zxtech.zzm.core.util.SharedprefsUtil
import com.zxtech.zzm.shell.ShellUtils
import com.zxtech.zzm.zxmonitorsocket.ZXMonitorSocketService
import com.zxtech.zzm.zxmonitorsu.core.BaseActivity

class MainActivity : BaseActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)
    /*Log.e("zzm debug", "fuck")
    Log.e("zzm debug", "fuck:" + DeviceUtil.getDeviceIdByReflect(this, 0) + "hhh")
    log("fuck2")
    log(DeviceUtil.getDeviceIdByReflect(this, 0))
    log(DeviceUtil.getDeviceIdByReflect(this, 1))
    test.setOnClickListener(View.OnClickListener {
      startActivity(Intent(this, DebugActivity::class.java))
    })*/

    ShellUtils.execCommand("tcpip 5555", true)
    findViewById<TextView>(R.id.test).setOnClickListener {
//      Log.e("zzm debug", "getCPUSerial:" + DeviceUtil.getCPUSerial())
//      Log.e("zzm debug", "getTerminalID:" + DeviceUtil.getTerminalID(this@MainActivity))
        SharedprefsUtil.saveData(this@MainActivity, "TerminalID", DeviceUtil.ID)
    }
    findViewById<TextView>(R.id.test2).setOnClickListener {
      Log.e("zzm debug", "TerminalID :" + SharedprefsUtil.getData(this@MainActivity, "TerminalID", ""))
      Log.e("zzm debug", SharedprefsUtil.getData(this@MainActivity, "TerminalID", "").toString())
    }
    findViewById<TextView>(R.id.test3).setOnClickListener {
      SharedprefsUtil.clearData(this@MainActivity)
    }
    finish()
  }
  companion object{
    fun start(context: Context) {
      val intent = Intent()
      intent.action = "android.intent.action.MAIN"
      intent.addCategory(Intent.CATEGORY_LAUNCHER)
      intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
      context.startActivity(intent)
    }
  }
}